//
//  XLPPFooterView.m
//  XiangLove
//
//  Created by 陈宪栋 on 2017/12/19.
//  Copyright © 2017年 BAOMIHUA.COM. All rights reserved.
//

#import "XLPPFooterView.h"

@interface XLPPFooterView ()
@property (nonatomic, strong) UIActivityIndicatorView *indicatorView;
@property (nonatomic, strong) UIImageView *emptyImageView;
@property (nonatomic, strong) UILabel *emptyLabel;
@end

@implementation XLPPFooterView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
//    self.backgroundColor = RGB(243, 243, 243);
    self.backgroundColor = [UIColor clearColor];
    
    _emptyImageView = [[UIImageView alloc] init];
    _emptyImageView.image = [UIImage imageNamed:@"common_content_def_d"];
    _emptyImageView.hidden = YES;
    [self addSubview:_emptyImageView];
    [_emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(84, 66));
        make.center.equalTo(self);
    }];
    
    _emptyLabel = [[UILabel alloc] init];
    _emptyLabel.font = [UIFont systemFontOfSize:14];
    _emptyLabel.textColor = RGB(144, 144, 144);
    _emptyLabel.text = @"暂无视频动态";
    [self addSubview:_emptyLabel];
    [_emptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_emptyImageView);
        make.top.equalTo(_emptyImageView.mas_bottom).offset(4);
    }];
    
    _indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
//    _indicatorView.transform = CGAffineTransformMakeScale(1.5, 1.5);
    _indicatorView.hidden = YES;
    [self addSubview:_indicatorView];
    [_indicatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
    }];
}

- (void)showEmptyView {
    self.emptyLabel.hidden = NO;
    self.emptyImageView.hidden = NO;
}

- (void)hideEmptyView {
    self.emptyLabel.hidden = YES;
    self.emptyImageView.hidden = YES;
}

- (void)showLoading {
    _indicatorView.hidden = NO;
    if ([_indicatorView isAnimating] == NO) {
        [_indicatorView startAnimating];
    }
}

- (void)hideLoading {
    _indicatorView.hidden = YES;
    if ([_indicatorView isAnimating]) {
        [_indicatorView stopAnimating];
    }
}
@end
